<?php


class member extends CI_Model{
    
    public function __construct(){
        parent::__construct(); 
        $this->load->database();
   }
    
   public function insertMember(){
       $this->load->library('ion_auth');
       
       $password = $_POST['password'];
       $promotion = (isset($_POST['promotion']))?$_POST['promotion']:"";
       $member = array('nom' => $_POST['nom'], 
                     'prenom' => $_POST['prenom'], 
                     'email' => $_POST['email'],
                     'civilite' => $_POST['civilite'],
                     'adresse1' => $_POST['adresse'],
                     'adresse2' => $_POST['adresse_suite'],
                     'codepostal' => $_POST['codepostal'],
                     'ville' => $_POST['ville'],
                     'pays' => $_POST['pays'],
                     'fixe'=> $_POST['fixe'],
                     'mobile' => $_POST['portable'],
                     'datenaissance' => $_POST['datenaissance'],
                     'est_newsletter' => $promotion
           
                );
      $additional_data = array(
				'first_name' => $this->input->post('prenom'),
				'last_name'  => $this->input->post('nom'));
     
      $member['user_id'] = $this->ion_auth->register($member['email'],$password, $member['email'], $additional_data);
      
      if ($this->db->insert('membre', $member)){
          return true;
      }
      else{
          return false;
      }
   }
}

?>
